import json

data = [1,2,3,4,5]
file_name = 'username.json'
    
def get_stored_username():
    """ 获取本地已经存储的用户名字 """
    try:
        with open(file_name,'r') as file_object:
            username = json.load(file_object)
    except FileNotFoundError:
        pass
        return None
    else:
        return username
        
def get_new_username():
    """ 创建新用户记录 """
    username = input("what\'s your name?")
    with open(file_name,'w') as file_object:
        json.dump(username,file_object)
    return username

def greet_user():
    """ 向所有用户打招呼 """
    username = get_stored_username()
    if username:
        #for name in allusernamelist:
        #    print("hello,"+name)
        print("hello,"+username)
    else:
        username = get_new_username()
        print(username + ",we will remenber your name!")

greet_user()

def SaveData(temp):
    """ 将temp数据保存到当前目录下的data.json文件中 """    
    with open(file_name,'w') as file_object:
        json.dump(temp,file_object)
def ReadData():
    """ 从当前目录下的data.json文件中读取数据 """
    file_name = 'data.json'
    with open(file_name,'r') as file_object:
        numbers = json.load(file_object)
    print(numbers)
